package com.njupt.webapp.tags;

import java.util.List;

import javax.servlet.jsp.JspException;

import com.njupt.dao.BaseDao;

/**
 * 输入hql语句，执行改语句，存储查询结果。
 *
 */
public class getEntityTag extends HqlBaseTag{
	private String objType;
	private Object objId;
	private String scope;
	
	public String getScope() {
		return scope;
	}
	public void setScope(String scope) {
		this.scope = scope;
	}
	public Object getObjId() {
		return objId;
	}
	public void setObjId(Object objId) {
		this.objId = objId;
	}
	public String getObjType() {
		return objType;
	}
	public void setObjType(String objType) {
		this.objType = objType;
	}

	public int doStartTag() throws JspException {
        if(objId == null || "".equals(objId))return super.doStartTag();
        BaseDao baseDao = this.getBaseDao();
        Object o = baseDao.queryForUnique("from "+objType+" c where c.id=?",new Object[]{ objId });
        TagUtils.saveToContext(this,pageContext,scope,o);
        return super.doStartTag();
    }
}
